package com.itheima.job;

import com.itheima.constant.SetTimeConStant;
import com.itheima.job.config.QuartzManager;
import org.springframework.stereotype.Component;

/**
 * @author LiangTianQi
 * @describe
 * @date 2020/11/16 20:47
 */

/**
 * 服务器启动，定时器加载的类
 */
@Component
public class StartTimeJob {

    //远程注入orderSettingService,该方案失败
    /*@Reference
    private static OrderSettingService orderSettingService;*/

    /*//生成静态的ordersettingjob
    @Autowired
    private static OrderSettingJob orderSettingJob;*/


    //任务名称
    private static String jobName= SetTimeConStant.JOB_NAME;
    //任务组名称
    private static String jobGroupName = SetTimeConStant.JOB_GROUP_NAME;

    //触发器名称
    private static String triggerName = SetTimeConStant.TRIGGER_NAME;
    //触发器组名称
    private static String triggerGroupName = SetTimeConStant.TRIGGER_GROUP_NAME;

    //静态初始的触发时间
    private static String cron = "0 0 0 25 * ?";



    //加载class文件是触发定时器
    static {
        //将orderSettingService当作参数传入OrderSettingJob中
        Class<OrderSettingJob> jobClass = OrderSettingJob.class;
        QuartzManager.addJob(jobName,jobGroupName,triggerName,triggerGroupName,jobClass,cron);
    }
}
